package com.inspur.cloud.configuration;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;


@Configuration
public class DataSourceConfig {

    @Bean(name = "dataspaceDataSource")
    @Qualifier("dataspaceDataSource")
    @ConfigurationProperties(prefix = "spring.dataspace.datasource")
    @Primary
    public DataSource dataspaceDataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "ambariDataSource")
    @Qualifier("ambariDataSource")
    @ConfigurationProperties(prefix = "spring.ambari.datasource")
    public DataSource ambariDataSource() {
        return DataSourceBuilder.create().build();
    }

}
